﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NS.BLL;

namespace Admin.Shop
{
    public partial class ShopLogin : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.isLogin) //判断是否登录
            {
                Response.Redirect("index.aspx");
            }
        }

        #region 登录
        protected void login_Click(object sender, ImageClickEventArgs e)
        {
            if (Session["ShopCheckCode"] != null)
            {
                if (Session["ShopCheckCode"].ToString().ToLower() != this.ValiDateCode.Text.ToLower())
                {
                    this.Message.Text = "验证码有误!";
                    Session["ShopCheckCode"] = null;
                    return;
                }
                else
                {
                    Session["ShopCheckCode"] = null;
                }
            }
            else
            {
                Response.Redirect("shoplogin.aspx");
                return;
            }

            string account = this.Account.Text.Trim().Replace(" ", "");
            string password = this.Password.Text.Trim().Replace(" ", "");
            NS.BLL.Shops shopBll = new Shops();
            int shopID = shopBll.VertifyShop(account, password);
            if (shopID > 0)
            {
                Session["ShopID"] = shopID.ToString();
                Response.Redirect("index.aspx");
            }
            else
            {
                this.Message.Text = "帐号或密码错误 !";
            }
        }
        #endregion
    }
}